home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
perfTuning
/
glprof.man
< prev
next >
Wrap
Text File
|
1994-08-01
|
28KB
|
570 lines
GLPROF(1) GLPROF(1)
NAME
glprof - profiling utility for IrisGL applications
SYNOPSIS
glprof [-n tracename] [ application ] [ -application_options ]
DESCRIPTION
glprof is an aid for profiling IrisGL applications. Future versions of
glprof will support OpenGL applications as well. glprof can be used to
understand the behavior and timing of visual simulation and animation
applications where the highest possible graphics performance and frame
rate are desired.
glprof captures traces of the IrisGL commands that an application calls,
times the execution of these commands on a simulator, and displays the
results in graphical and textual form. Optionally, object tags can be
inserted into the application's source code to aid in understanding the
profile display. Host CPU times are also reported if the trace is
captured on a machine equipped with a free running hardware cycle
counter.
OPTIONS
-d database
Directory for traces. Default is ./glf/
-n tracename
Name for traces. Default is the name of the application.
PROCEDURE
This is a general procedure to profile an IrisGL application:
Insert object tags (optional)
glprof allows you to associate an object tag with each IrisGL command.
Each object tag is a hierarchical name composed of nonzero integer object
numbers, e.g. 17/32/69/91. Object tags can be specified using the IrisGL
name stack commands initnames(), loadname(), pushname(), and popname().
The name stack commands can be used either in immediate mode or in
display lists. When an IrisGL application is not running under glprof,
these commands are used for picking and selection as usual and are
ignored outside of picking and selecting mode. When an IrisGL
application is running under glprof these commands are executed as usual
by IrisGL, but they are also stored in the traces that are captured (even
when the application is not in picking or selecting mode).
When a trace is profiled, glprof interprets the stored name stack
commands. The object tag for each GL command in the trace is defined to
be the value of the name stack that is current when that command is
executed by the profiler.
Page 1
GLPROF(1) GLPROF(1)
You can use the command
extern void glpObject(unsigned int inNum, const char *inName);
in your IrisGL application to associate a string name with a nonzero
integer object number. This command is ignored when the application is
not running under glprof. It is also ignored if inNum is zero. It is
typically called during application initialization, but it may be called
at any time. It is always executed immediately, even when IrisGL is in
display list mode. It is legal to call glpObject() multiple times with
the same value of inNum. When glpObject() is called, the association
between inNum and inName does not take effect until inNum is used in a
loadname() or pushname() command. If string object names are specified,
the profile display will use them in place of integer object numbers.
In previous releases of glprof, the command
extern void glprof_object(const char *inName);
could be used in IrisGL applications to insert object tags into traces.
For backward compatibility only, this command is still supported. It has
been reimplemented using the new object tag scheme, as follows:
void glprof_object(const char *inName) {
if (tracing && getopenobj() == -1) { /* no-op if display list mode */
glpObject(0x10000, inName);
trace_glLoadName(0x10000);
}
}
Note that unlike previous implementations, the new implementation of
glprof_object does nothing if IrisGL is in display list mode. If you
need to tag an object in a display list, simply call loadname(), and call
glpObject() during application initialization to associate a string with
the integer object number.
In previous releases, glprof_object() was implemented in
/usr/lib/libglprof.a. Since the implementation of glprof_object is now
built into glprof itself, /usr/lib/libglprof.a is no longer needed and is
not present in the current release. Existing IrisGL executables that
were linked with -lglprof must be relinked without -lglprof in order to
use the new object tag scheme.
In previous releases, the implementation of glprof_object() used the
IrisGL command charstr(), and as a result it was necessary to use the
IrisGL command cmov() before calling glprof_object() in order to prevent
object tags from appearing as character strings in the scene being
rendered. This is no longer necessary.
Run glprof
Page 2
GLPROF(1) GLPROF(1)
e.g.
glprof myapp -f myarg1 -g myarg2
Capture traces
Select the Capture button. glprof runs the application under the control
of the trace capturer. The application must be either a COFF executable
(IRIX 4.0.5 or earlier) linked with /usr/lib/libgl_s, an ELF executable
(IRIX 5.0 or later) linked with /usr/lib/libgl.so, or a shell script that
starts an ELF executable that is linked with /usr/lib/libgl.so. When the
application is at the desired frame, move the mouse cursor into the
window to be traced and press the Pause key on the keyboard to capture a
single-frame trace. Hold the key down until the mouse cursor turns into
an hourglass or until you hear a beep, then release the key. You can
capture as many traces as you want. When you are done, exit the
application normally. For tracing to succeed, the application must be
continuously drawing frames and calling [m]swapbuffers() between frames
in the window that the mouse cursor is in while you are holding down the
Pause key.
View the trace
Select a trace name in the trace list window with the left mouse button.
Press the View button. The viewing window may be reshaped as desired.
Select simulation options
Traces can be simulated on various hardware configurations. Several
simulation parameters can be taken from the trace (Pass), or forced to
assume some other value for simulation timing purposes.
Simulate and display profile results
Select the trace name and press the Profile button. The profile display
window shows two bar graphs representing a simplified graphics pipeline,
with the upper one a magnified view of the lower one. Bars report
activity of the Host CPU, Graphics Library, Transformation stage,
Clipping stage, Span generation stage, and pixel Fill stage. With the
cursor below the mid-line, use the left mouse button to manipulate the
magnification left and right limits. The upper bar graph also shows
object tag names and a bold line following the object into the graphics
pipeline. Select an object with the left mouse button to obtain a
textual summary of the object.
DEFAULT SETTINGS
glprof reads the files ~/.glprofrc and ./.glprofrc to obtain default
settings for various parameters:
# comments start with #
Prog = flight -D defs # Default: ""
Trace = wingman # Default: Prog[0] (e.g. "flight")
Comp = 1 # Options: { 1,2,3,4 } Default: 1
Filter = MIP Pnt # Options: { Point,Bilinear,MIP Pnt,MIP Lin,
# MIP Biln,MIP Tri } Default: Point
Page 3
GLPROF(1) GLPROF(1)
Fog = Pass # Options: { Pass,On,Off } Default: Pass
Graphics = RE # Options: { VGX,VGXT,RE } Default: RE
Host = Off # Options: { Pass,Off } Default: Off
Spans = 10 # Options: { 5,10,20 } Default: 10
Texture = On # Options: { Pass,On,Off } Default: Pass
Window = 100 x 200 # Default: Pass
Database = /usr/tmp/glf # Default: ./glf
SharedThreshold = 1024 # Default: 4096
TraceKey = 162 # Default: 160 (PAUSEKEY; see <gl/device.h>)
TraceTextures = On # Options: { On,Off } Default: On
FILES
~/.glprofrc ./.glprofrc
default control settings.
./glf
default database location.
/usr/sbin/glprof
the profiler.
/usr/sbin/glprof_disp
the profile display program, forked by glprof.
/usr/sbin/glprof_sim
the simulator, forked by glprof.
/usr/sbin/glfcat
program that you can use to write traces to standard output in
human-editable text form.
/usr/sbin/glftrace
program to capture traces, forked by glprof.
/usr/sbin/glfview
program to view traces, forked by glprof.
/usr/lib/libgltrace.so
run-time tracing library used by glftrace.
/usr/lib/GLS/libGL.so
instrumented OpenGL library, used by glprof_sim.
/usr/lib/GLS/libGLcore.so
instrumented OpenGL library, used by glprof_sim.
/usr/lib/X11/dyDDX/glx.so
GLX extension to the X server (see BUGS, below)
Page 4
GLPROF(1) GLPROF(1)
TRACE FILES
Each trace is stored as three files in the directory
<database>/<tracename>/. The directory will be created if it does not
already exist. Each file name begins with a decimal sequence number.
The file <num>.eglf is the header file, which contains references to the
other two files: the initialization file (<num>init.glf), which
establishes the GL state at the beginning of the traced frame, and the
scene file (<num>scene.glf), which contains the GL commands traced
between adjacent [m]swapbuffers() commands. The header file is a human-
editable text file, while the other two are compact binary files.
If your application uses fonts and/or textures, fonts and texture images
larger than a certain size threshold will be stored in separate binary
files called font<checksum>.glf and tex<checksum>.glf in the directory
<database>/SHARED/. The initialization file of each trace will contain
references to these shared files, rather than including the fonts and
texture images directly. This yields significant savings in disk space
when you capture many traces. The default size threshold is 4096 bytes.
To set the size threshold to n bytes, put "SharedThreshold = n" in
~/.glprofrc or ./.glprofrc.
When you delete a trace that references one or more files in
<database>/SHARED, the referenced files will not be deleted. To
eliminate all files in <database>/SHARED that are no longer referenced by
any trace, use the Scavenge Shared Files item in the Actions menu.
If you don't have enough disk space to store traced texture images, put
"TraceTextures = Off" in ~/.glprofrc or ./.glprofrc. This will force the
size of all traced texture images to be 1x1 pixels.
The trace file format used by glprof in releases prior to IRIX 5.2 is no
longer supported. Trace files in the old format cannot be interpreted by
glprof.
Although the current release of glprof can only trace IrisGL applications
and not OpenGL applications, the trace file format is OpenGL-based. The
trace capturer translates IrisGL commands to equivalent OpenGL commands.
Since it is impossible to perform this translation perfectly, some IrisGL
applications may not be traced properly. In most cases, incorrect
translation will produces an erroneous visual effect in the viewer but
not affect the performance simulation done by the profiler. In many
cases, a small change to the IrisGL application can solve the problem.
If your application is not traced properly, see the next section for more
details.
The trace file format is still under development as a general purpose
OpenGL metafile mechanism. SGI plans to support the metafile standard
that is eventually adopted by the OpenGL community. It is likely that
the eventual standard will be at least somewhat different from the
current file format. As a result, SGI does not guarantee that trace
files in the current format will be supported in future releases.
Page 5
GLPROF(1) GLPROF(1)
You can use the commands in the Edit menu to open a text editor on a
trace's header file, initialization file, or scene file. Note that the
OpenGL commands in the header and initialization files are used only to
establish the correct initial GL state. The profiler considers only the
OpenGL commands in the scene file.
Since the trace file format is still under development and subject to
change, it is not documented in the current release. The syntax is
similar to C source code. The OpenGL API is defined in <GL/gl.h>. You
may find it useful to edit trace files to make changes to OpenGL command
parameters (e.g., disable texturing in certain places) and then view and
profile the changed trace. To comment out a line, insert a pound sign
(#) at the beginning of the line. You can leave the viewer running as
you are editing the file; when you want to see the results of a change,
move the mouse cursor into the viewer window and type <Enter>. This will
cause the viewer to reread the trace.
If you edit an initialization file or scene file, glprof converts the
file from the default compact binary format to a human-editable format.
Since files are much larger and are processed much more slowly when they
are in the human-editable format, you may want to use the Recompress
command in the Edit menu when you are done editing. This command
converts the initialization and scene files of the selected trace(s) back
to the compact binary format.
TRACE CAPTURER LIMITATIONS
The following paragraphs identify situations in which the IrisGL-to-
OpenGL translator in the trace capturer may fail.
The translator ignores IrisGL commands and modes that have no equivalent
in OpenGL or the OpenGL GLU utility library.
In the current release, the translator ignores several IrisGL commands
that do have equivalents in OpenGL or GLU:
curveit()
lrectwrite()
rectcopy()
rectwrite()
writeRGB()
writepixels()
Old-style IrisGL curve commands (crv(), crvn(),
patch(), rcrv(), rcrvn(), rpatch()) are
represented in traces as line segments connecting the curve control
points.
If IrisGL object editing is done while a frame is being traced, the
editing commands and their effects will not appear in the trace. The
edits will, however, affect subsequent traces.
Page 6
GLPROF(1) GLPROF(1)
If an mmode() command inside an IrisGL object changes the number of
IrisGL matrices (singlematrix/multimatrix) while a frame is being
traced, the appropriate commands to clear the OpenGL MODELVIEW matrix
stack will fail to appear in the trace.
If the traced application relies on the fact that on some IrisGL
implementations the ModelView matrix is not applied when in
MPROJECTION mode, the translator will fail.
If an IrisGL object contains an ortho(), ortho2(),
perspective(), or window() command, and if the number of
IrisGL matrices (singlematrix/multimatrix) is different when the
object is called from what it was at the beginning of the frame, the
translator will fail.
The IrisGL pushattributes() command is traced as an OpenGL
glPushAttrib() command that saves a superset of the attributes
that should be saved:
glPushAttrib(
GL_COLOR_BUFFER_BIT |
GL_CURRENT_BIT |
GL_ENABLE_BIT |
GL_LIGHTING_BIT |
GL_LINE_BIT |
GL_LIST_BIT |
GL_POLYGON_STIPPLE_BIT
);
In other words, attributes are pushed in the OpenGL execution that
were not pushed in the IrisGL execution. If the application changes
the value of these "extra" attributes and relies on the changed values
being preserved after an ensuing popattributes() command, the
translator will fail.
While IrisGL has separate viewport and attribute stacks, in OpenGL
all attributes are pushed onto a single stack. This can lead to
problems:
pushattributes(); -> glPushAttrib(ATTRIB_MASK);
pushviewport(); -> glPushAttrib(VIEWPORT_MASK);
popattributes(); -> glPopAttrib();
<commands> -> <commands>
popviewport(); -> glPopAttrib();
In this example, if <commands> relies on the attributes (and not the
viewport) being popped, the translator will fail.
If the frontbuffer(), backbuffer(), leftbuffer(),
rightbuffer(), or zdraw() commands are used in an IrisGL
object, the translator may fail.
Page 7
GLPROF(1) GLPROF(1)
If lmbind() is called with a nonzero index inside an IrisGL object,
the translator will generate an OpenGL command to enable OpenGL lighting
if the target is either LMODEL or MATERIAL. Since IrisGL enables lighting
only if both LMODEL and MATERIAL are bound to a nonzero index, lighting
might be enabled in the OpenGL execution at times when it shouldn't be.
If texbind(TX_TEXTURE_0, i) or tevbind(TV_ENV0, i) is called with i != 0
inside an IrisGL object, the translator will generate an OpenGL command
to enable OpenGL texturing. Since IrisGL enables texturing
only if both TX_TEXTURE_0 and TV_ENV0 are bound to a nonzero index,
texturing might be enabled in the OpenGL execution at times when it
shouldn't be.
If the IrisGL color/normal flag is used to enable and disable lighting
within an IrisGL object, the translator may fail.
If lmbind(MATERIAL, n) is used to enable or disable IrisGL lighting within
an IrisGL bgn/end pair, the translator will fail.
If lmcolor() is used within an IrisGL bgn/end pair, the translator will
fail.
If swaptmesh() is called inside an IrisGL object that does not also
directly contain all of the IrisGL commands from the preceding
bgntmesh() to the following endtmesh(), the translator will fail.
If backface() and frontface() are both used, and if one or
both of these commands are called inside an IrisGL object, the
translator may fail.
If the traced application uses concave polygons, the translator may
fail.
If the traced application draws polygons with shademodel(FLAT),
the translator may produce a trace with incorrect colors. The color
of each flatshaded polygon will be that of the first vertex (the
OpenGL convention), not the last vertex (the IrisGL convention).
If the traced application uses depth cueing, the translator may
produce a trace with incorrect colors.
If winset(), GLXwinset(), or [m]swapbuffers() is
called while IrisGL is in feedback, picking, or selecting mode, the
translator will fail.
If [m]swapbuffers() is called while IrisGL is in object-creation
mode, the translator will fail.
If the application loads textures using the TX_PIXMODE external format
or the commands subtexload() or fbsubtexload(), the
textures in the trace will be solid gray.
Page 8
GLPROF(1) GLPROF(1)
NOTES
If your IrisGL application has errors that cause warnings when you run
the application under gldebug, the trace capturer may fail. If you have
trouble capturing traces, use gldebug to check the correctness of your
application.
Some IrisGL applications obtain input via a transparent X window covering
the GL rendering window. This has the side effect of preventing IrisGL
from receiving keyboard button events. To capture a trace from such a
program, you should use a .glprofrc file to set the TraceKey to the left,
middle, or right mouse button (101, 102, or 103, respectively, as defined
in <gl/device.h>).
If your IrisGL application is single-buffered, you can capture traces
from it if you add a swapbuffers() command at the end of each frame.
This command will have no effect when you application is not running
under glprof.
If you run a program under the trace capturer, and that program starts
other programs, those programs will also run under the trace capturer.
For example, if you run the demo shell program (/usr/demos/bin/buttonfly)
under the trace capturer, you can capture traces from any of the IrisGL
programs that buttonfly starts. This rule does not apply to COFF (IRIX
4.0.5 or earlier) executables. If the traced program tries to start an
OpenGL program, the OpenGL program will fail to run.
The current release of glprof runs on any SGI graphics system and
supports the simulation of the following SGI graphics systems: VGX,
VGXT, and RealityEngine. If your target graphics system is not in this
set, glprof can still be a very useful tuning tool. In particular, much
of the information in the the textual profile display is independent of
the particular graphics system being simulated.
An application that uses display lists may run very slowly under the
trace capturer if the application is rendering to a remote display. The
reason for this is that the trace capturer forces display lists to be
created on the machine that the application is running on, not the remote
machine.
The program /usr/sbin/glfcat writes a trace to standard output in human-
editable text form. Use the -h option to get a list of the available
options. Use the -r (recursive) option to include the contents of
referenced files instead of just their names. Since traces can be large,
you will probably want to pipe the output to a file, e.g.:
glfcat -r flight/0.eglf > flight.eglf
The viewer supports a small number of single-character keyboard commands.
Some of these commands cause the viewer to write text to its standard
output. With the mouse in the viewer window, type h for a list of
commands.
Page 9
GLPROF(1) GLPROF(1)
Of particular interest is the viewer's timing loop command (t). The
viewer measures the time to draw a frame using OpenGL, and the result
appears in the viewer window title. The measured frame time should be
interpreted as a very loose upper bound on the time your application
would take to draw a frame using IrisGL if it spent no time between GL
calls.
The measured frame time is a very loose upper bound for two reasons.
First, in the current release the viewer has not yet been tuned for
maximum OpenGL drawing performance. Second, the translation from the
IrisGL commands generated by your application to the OpenGL commands
stored in traces is generally accurate enough for performance simulation
purposes, but in many cases the simple-minded automatic translation
produces significant inefficiencies in the OpenGL execution that do not
occur in the IrisGL execution (and would also not occur if you actually
ported your application to OpenGL). For example, the IrisGL drawmode()
command is translated to an OpenGL command sequence that produces
visually correct results in the viewer but is quite slow.
BUGS
If OpenGL is not available on your system, glprof will still work, but
the View button will be grayed out and /usr/sbin/glfview will not work.
If you install the optional gl_dev.sw.glprof software subsystem on a
system that does not support OpenGL, the X server will erroneously report
that it supports the GLX (OpenGL) extension to the X protocol, even
though it does not in fact support this extension. This is due to the
presence of the file /usr/lib/X11/dyDDX/glx.so, which is necessary for
the proper functioning of glprof_sim. If your system does not support
OpenGL, this file will be present only if you have installed
gl_dev.sw.glprof, and its presence will not cause your system to support
OpenGL. If your system does not support OpenGL, and you install
gl_dev.sw.glprof while the system is running using the IRIX (not
miniroot) software installation technique, you must restart the X server
so that it will recognize the presence of /usr/lib/X11/dyDDX/glx.so.
The Profile command will fail if the machine that is used to run glprof
does not have a local graphics display and an X server running, even if
the DISPLAY environment variable is used to place the glprof window on
another machine. This restriction is due to limitations in the
implementation of glprof_sim.
If the traced application uses IrisGL objects, the Capture command will
not work if the machine that is used to run glprof (and the traced
application) does not have a local graphics display, even if the DISPLAY
environment variable is used to place the glprof and application windows
on another machine. This restriction is due to limitations in the
implementation of glftrace.
The mechanism that glprof uses to measure host CPU times tends to
overestimate the time that your application spends between GL commands.
Unfortunately, there is no convenient way to determine how large this
Page 10
GLPROF(1) GLPROF(1)
error is. If the measured host times seem excessive, use the "Host" menu
item to force the simulator to ignore host times. More accurate results
for host time can be obtained with pixie(1) and prof(1).
Not all IrisGL drawing commands and modes are simulated.
In the current release, OpenGL applications cannot yet be traced.
SEE ALSO
gldebug(1), pixie(1), prof(1)
Page 11